package com.thrd.basicframework.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

/**
 * @author: ${唐杰}
 * @date: 2021/3/12
 */
public class TouchViewPager extends ViewPager {
    private OnTouchChangeListener onTouchChangeListener;
    public TouchViewPager(@NonNull Context context) {
        super(context);
    }

    public TouchViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if(onTouchChangeListener!=null){
            onTouchChangeListener.onTouchEvent(event);
        }
        return super.onTouchEvent(event);

    }

    public OnTouchChangeListener getOnTouchChangeListener() {
        return onTouchChangeListener;
    }

    public void setOnTouchChangeListener(OnTouchChangeListener onTouchChangeListener) {
        this.onTouchChangeListener = onTouchChangeListener;
    }

    public interface OnTouchChangeListener{
        void onTouchEvent(MotionEvent event);
    }

}
